/**
 * Created by 断崖 on 2017/2/10.
 */
function MVVM(options) {
    this.$options = options;
    var data = this.$data = options.data;

    observer(data);

    // 数据代理
    var self = this;
    Object.keys(data).forEach(function (key) {
        self.$proxy(key);
    });

    this.$directives = new Compile(options.el || document.body, this);
}

MVVM.prototype = {
    $proxy: function (key) {
        var self = this;
        Object.defineProperty(this, key, {
            enumerable: true,
            configurable: false,
            get: function () {
                return self.$data[key];
            },
            set: function (value) {
                self.$data[key] = value;
            }
        })
    }
};